#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;
const int maxn=500000;
int n, p, q, r, a[maxn+1], b[maxn+1], c[maxn+1], h, t;
ll area, x[maxn+2], y[maxn+2];

void sort(int size, int *k, int *a, int *b, int *c) {
    static int cnt[maxn+1], u[maxn+1], v[maxn+1], w[maxn+1];
    memset(cnt, 0, sizeof cnt);
    for (int i=1; i<=n; i++) cnt[k[i]]++;
    cnt[0] = 0;
    for (int i=1; i<=size; i++) cnt[i] += cnt[i-1];
    for (int i=1; i<=n; i++) {
        int t=cnt[k[i]]--;
        u[t]=a[i], v[t]=b[i], w[t]=c[i];
    }
    for (int i=1; i<=n; i++) a[i]=u[i], b[i]=v[i], c[i]=w[i];
}

void pushb(ll u, ll v) {
    for (; v>=y[t] && u>=x[t] && t>=h; t--) area+=y[t]*(x[t]-x[t-1]);
    if (h>t || (v<y[t] && u>x[t])) {
        area -= v*(u-x[t]);
        x[++t] = u;
        y[t] = v;
    }
}

void pushf(ll u, ll v) {
    for (; u>=x[h] && v>=y[h] && h<=t; h++) area+=x[h]*(y[h]-y[h+1]);
    if (h>t || (u<x[h] && v>y[h])) {
        area -= u*(v-y[h]);
        x[--h] = u;
        y[h] = v;
    }
}

int main() {
    freopen("whiskey.in", "r", stdin);
    freopen("whiskey.out", "w", stdout);

    scanf("%d %d %d %d", &n, &p, &q, &r);
    area=(ll)p*q;
    for (int i=1; i<=n; i++) scanf("%d %d %d", a+i, b+i, c+i);

    h = 0;
    x[0]=0, y[0] = q;
    sort(p, a, a, b, c);
    for (int i=1; i<=n; i++) pushb(a[i], b[i]);
    pushb(p, 0);

    ll ans=0;
    sort(r, c, a, b, c);
    for (int z=r, pos=n; z; z--) {
        for (; c[pos]>=z; pos--) {
            pushf(a[pos], q);
            pushb(p, b[pos]);
        }
        ans += area;
    }
    printf("%lld\n", ans);

    fclose(stdin);
    fclose(stdout);
    return 0;
}
